Skip to content

[13.x] Add Postgres transaction pooler support#60425

Open
DGarbs51 wants to merge 3 commits into
13.xfrom
postgres-transaction-mode-proxy-support
Open

[13.x] Add Postgres transaction pooler support#60425
DGarbs51 wants to merge 3 commits into
13.xfrom
postgres-transaction-mode-proxy-support

Conversation

@DGarbs51

@DGarbs51 DGarbs51 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add PostgreSQL transaction-pooler support with pooled application connections and a direct connection variant for schema and maintenance workflows.
  • Enable emulated prepares for pooled PostgreSQL connections while keeping direct connections on native prepares by default.
  • Add ::direct routing for the database manager, migrations, schema dump/load, and maintenance commands.
  • Preserve explicit ::read, ::write, --read, --write, and --pooled routing, and make php artisan db default to direct only when pooled mode is enabled.
  • Handle boolean bindings correctly when PostgreSQL uses PDO-side emulated prepares.

Benefit to end users

Many PostgreSQL providers, including Neon and PlanetScale through PgBouncer and AWS RDS Proxy, use transaction-mode pooling. Today, Laravel users must handle prepared statement behavior, boolean binding edge cases, and direct DDL routing themselves. This gives Laravel applications a framework-level path for using PostgreSQL connection proxying and pooling without custom connection wrappers.

Backward compatibility

  • Default PostgreSQL connections without pooled => true or a configured direct endpoint keep the existing native-prepare behavior.
  • Existing read/write connection suffixes and CLI flags remain explicit and are not rerouted to direct.
  • php artisan db only defaults to direct when pooled mode is enabled and a direct endpoint exists, so adding a direct endpoint alone does not change the default interactive CLI target.
  • Boolean binding behavior is unchanged for native prepares and only adjusts PostgreSQL emulated prepares to send true / false strings instead of integer literals.
  • PGSSLMODE is only exported for schema dump/load when an sslmode value is configured.

Tests

  • vendor/bin/pint src/Illuminate/Database/PostgresConnection.php src/Illuminate/Database/Schema/PostgresSchemaState.php tests/Database/DatabasePostgresSchemaStateTest.php
  • vendor/bin/phpunit tests/Database
  • vendor/bin/phpunit tests/Integration/Foundation/CloudTest.php
  • vendor/bin/phpunit tests/Integration/Database/Postgres/DatabasePgsqlPooledConnectionTest.php (skipped locally when the PostgreSQL test database is unavailable)
  • git diff --check

@DGarbs51 DGarbs51 changed the title [13.x] - Add Postgres transaction pooler support [13.x] Add Postgres transaction pooler support Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant